<?php

namespace App\Modules\Admin\Requests;

use Illuminate\Foundation\Http\FormRequest;

class CategoryForm extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $validator = [
            'name' => 'required',
            'sort' => 'required|numeric',
        ];

        $id = $this->input('id');
        if (isset($id)) {

        } else {

        }
        return $validator;
    }

    public function messages()
    {
        return [
            'name.required' => '请填写分类名称',
            'sort.required' => '请填写排列顺序',
            'sort.numeric'  => '排序字段只能是数字'
        ];
    }
}
